package org.ar.gameserver.login.main;

import org.ar.gameserver.common.exception.ExceptionType;
import org.ar.gameserver.common.exception.GameServerException;
import org.ar.gameserver.common.socket.ServerSocket;
import org.ar.gameserver.common.util.LogUtils;
import org.ar.gameserver.common.util.PropertiesUtils;
import org.ar.gameserver.login.server.LoginServerHandler;
import org.ar.gameserver.login.server.PolicyServerHandler;

public class ExecuteManager {

	private static int loginBindPort;
	private static int policyBindPort;
	
	static {
		try {
			PropertiesUtils.load("/arg.properties");
			loginBindPort = Integer.parseInt(PropertiesUtils.getProperty("login.bind.port"));
			policyBindPort = Integer.parseInt(PropertiesUtils.getProperty("policy.bind.port"));
		} catch (Exception e) {
			LogUtils.error(e);
		}
	}
	
	public ExecuteManager() throws GameServerException {
		try {
			ServerSocket loginServer = new ServerSocket();
			ServerSocket policyServer = new ServerSocket();
			loginServer.start(new LoginServerHandler(), loginBindPort);
			policyServer.start(new PolicyServerHandler(), policyBindPort);
		} catch (Exception e) {
			throw new GameServerException(ExceptionType.EX_1, e);
		}
	}
}
